package com.qidian.buy.util.pojo;

import java.util.List;

/**
 * @Author 戴着假发的程序员
 * @company 起点编程
 * @date 2023/5/18-14:35
 * @TODO
 */
public class BuyResult<T> {
    private int code = 0;// 状态码
    private String msg = "";// 消息
    private Long count;// 总条数
    private List<T> data;// 数据列表
    private T obj;// 单个数据对象

    public static BuyResult ok(){
        BuyResult result = new BuyResult();
        result.setCode(200);
        result.setMsg("OK");
        return result;
    }
    public static BuyResult ok(String msg){
        BuyResult result = new BuyResult();
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }
    public static BuyResult ok(Object obj){
        BuyResult result = new BuyResult();
        result.setCode(200);
        result.setObj(obj);
        return result;
    }
    public static BuyResult ok(String msg,Object obj){
        BuyResult result = new BuyResult();
        result.setCode(200);
        result.setMsg(msg);
        result.setObj(obj);
        return result;
    }

    public static  BuyResult fal(){
        BuyResult result = new BuyResult();
        result.setCode(500);
        return result;
    }
    public static  BuyResult fal(String msg){
        BuyResult result = new BuyResult();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }
}
